package com.tj.api.utils;

import com.tj.bo.common.conf.enums.AppRequestTypeEnum;
import com.tj.template.config.vo.RequestBasicInfo;
import org.apache.commons.lang3.StringUtils;

/**
 * @program: binary-option
 * @description
 * @author: binary
 * @create: 2020-07-23 21:14
 **/
public class VersionUtils {

    public static boolean version_more_than_1_0_1(RequestBasicInfo requestBasicInfo) {

        if (requestBasicInfo == null) {
            return false;
        }

        if (StringUtils.isEmpty(requestBasicInfo.getPlatform())
                || requestBasicInfo.getPlatform().equals(AppRequestTypeEnum.WAP.getName())) {
            return false;
        }

        if (StringUtils.isNotEmpty(requestBasicInfo.getPlatform())) {
            if (requestBasicInfo.getPlatform().equals(AppRequestTypeEnum.ANDROID.getName())
                    && requestBasicInfo.getVersionCode() != null
                    && requestBasicInfo.getVersionCode() >= 4) {
                return true;
            }
        }

        return false;
    }

    public static boolean version_more_than_1_0_8(RequestBasicInfo requestBasicInfo) {

        if (requestBasicInfo == null) {
            return false;
        }

        if (StringUtils.isEmpty(requestBasicInfo.getPlatform())
                || requestBasicInfo.getPlatform().equals(AppRequestTypeEnum.WAP.getName())) {
            return false;
        }

        if (StringUtils.isNotEmpty(requestBasicInfo.getPlatform())) {
            if (requestBasicInfo.getPlatform().equals(AppRequestTypeEnum.ANDROID.getName())
                    && requestBasicInfo.getVersionCode() != null
                    && requestBasicInfo.getVersionCode() >= 10) {
                return true;
            }
        }

        return false;
    }
}
